package com.bumblebee.server.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class PurchaseOrder extends AbstractEntity{

	@ManyToOne
	private Supplier supplier;
	
	@Column(nullable = false)
	private Long voucherNo;
	
	@Column(nullable = false)
	private Long invoiceNo;
	
	@Column(nullable = false)
	private Date invoiceDate;
	
	private String tin;
	
	private String cst;
	
	@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
	@JoinColumn(name = "po_id")
	private Set<PurchaseItem> purchasedItems = new HashSet<PurchaseItem>(0);
	
	private Double totalPrice;

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public Long getVoucherNo() {
		return voucherNo;
	}

	public void setVoucherNo(Long voucherNo) {
		this.voucherNo = voucherNo;
	}

	public Long getInvoiceNo() {
		return invoiceNo;
	}

	public void setInvoiceNo(Long invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	public Date getInvoiceDate() {
		return invoiceDate;
	}

	public void setInvoiceDate(Date invoiceDate) {
		this.invoiceDate = invoiceDate;
	}

	public String getTin() {
		return tin;
	}

	public void setTin(String tin) {
		this.tin = tin;
	}

	public String getCst() {
		return cst;
	}

	public void setCst(String cst) {
		this.cst = cst;
	}

	public Set<PurchaseItem> getPurchasedItems() {
		return purchasedItems;
	}

	public void setPurchasedItems(Set<PurchaseItem> purchasedItems) {
		this.purchasedItems = purchasedItems;
	}

	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		this.totalPrice = totalPrice;
	}
	
	public void addItem(PurchaseItem item){
		this.purchasedItems.add(item);
	}
}
